package com.tt.vtg.scenario.util;

import java.io.IOException;
import java.io.InputStream;
import java.util.Optional;
import java.util.Properties;

public enum ValueUtils {
    INSTANCE;
    private Properties prop = new Properties();
    ValueUtils(){
        InputStream in = ValueUtils.class.getResourceAsStream("/setting.properties");
        try {
            prop.load(in);
        } catch (IOException e) {
            System.err.println("Load setting.properties occur exception!");
            e.printStackTrace();
        }
    }

    public static String get(String key) {
        return Optional.ofNullable(ValueUtils.INSTANCE.prop.getProperty(key)).
                orElseThrow(()->new RuntimeException(key+" does not exists."));
    }
}
